/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: nu uc
 * License Type: Evaluation
 */
package org.testis.orm.classes;

import org.orm.*;

public class T_bed_devicegroup_details {
    public T_bed_devicegroup_details() {
    }

    public boolean save() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .saveObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean delete() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .deleteObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean refresh() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().refresh(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean evict() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().evict(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate() throws PersistentException {
	try {
	    if (getGroup() != null) {
		getGroup().t_bed_devicegroup_details.remove(this);
	    }

	    if (getPc() != null) {
		getPc().t_bed_devicegroup_details.remove(this);
	    }

	    if (getOs() != null) {
		getOs().t_bed_devicegroup_details.remove(this);
	    }

	    return delete();
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate(org.orm.PersistentSession session)
	    throws PersistentException {
	try {
	    if (getGroup() != null) {
		getGroup().t_bed_devicegroup_details.remove(this);
	    }

	    if (getPc() != null) {
		getPc().t_bed_devicegroup_details.remove(this);
	    }

	    if (getOs() != null) {
		getOs().t_bed_devicegroup_details.remove(this);
	    }

	    try {
		session.delete(this);
		return true;
	    } catch (Exception e) {
		return false;
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    private void this_setOwner(Object owner, int key) {
	if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DEVICEGROUP_DETAILS_GROUP) {
	    this.Group = (org.testis.orm.classes.T_bed_devicegroup) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DEVICEGROUP_DETAILS_PC) {
	    this.Pc = (org.testis.orm.classes.T_bed_testpc) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DEVICEGROUP_DETAILS_OS) {
	    this.Os = (org.testis.orm.classes.T_bed_os) owner;
	}
    }

    org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
	public void setOwner(Object owner, int key) {
	    this_setOwner(owner, key);
	}

    };

    private int id;

    private org.testis.orm.classes.T_bed_devicegroup Group;

    private org.testis.orm.classes.T_bed_testpc Pc;

    private String macAddress;

    private String ip;

    private int port;

    private org.testis.orm.classes.T_bed_os Os;

    private boolean isRemote;

    private String name;

    private void setId(int value) {
	this.id = value;
    }

    public int getId() {
	return id;
    }

    public int getORMID() {
	return getId();
    }

    public void setMacAddress(String value) {
	this.macAddress = value;
    }

    public String getMacAddress() {
	return macAddress;
    }

    public void setIp(String value) {
	this.ip = value;
    }

    public String getIp() {
	return ip;
    }

    public void setPort(int value) {
	this.port = value;
    }

    public int getPort() {
	return port;
    }

    public void setIsRemote(boolean value) {
	this.isRemote = value;
    }

    public boolean getIsRemote() {
	return isRemote;
    }

    public void setName(String value) {
	this.name = value;
    }

    public String getName() {
	return name;
    }

    public void setGroup(org.testis.orm.classes.T_bed_devicegroup value) {
	if (Group != null) {
	    Group.t_bed_devicegroup_details.remove(this);
	}
	if (value != null) {
	    value.t_bed_devicegroup_details.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_devicegroup getGroup() {
	return Group;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_Group(
	    org.testis.orm.classes.T_bed_devicegroup value) {
	this.Group = value;
    }

    private org.testis.orm.classes.T_bed_devicegroup getORM_Group() {
	return Group;
    }

    public void setPc(org.testis.orm.classes.T_bed_testpc value) {
	if (Pc != null) {
	    Pc.t_bed_devicegroup_details.remove(this);
	}
	if (value != null) {
	    value.t_bed_devicegroup_details.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_testpc getPc() {
	return Pc;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_Pc(org.testis.orm.classes.T_bed_testpc value) {
	this.Pc = value;
    }

    private org.testis.orm.classes.T_bed_testpc getORM_Pc() {
	return Pc;
    }

    public void setOs(org.testis.orm.classes.T_bed_os value) {
	if (Os != null) {
	    Os.t_bed_devicegroup_details.remove(this);
	}
	if (value != null) {
	    value.t_bed_devicegroup_details.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_os getOs() {
	return Os;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_Os(org.testis.orm.classes.T_bed_os value) {
	this.Os = value;
    }

    private org.testis.orm.classes.T_bed_os getORM_Os() {
	return Os;
    }

    public String toString() {
	return toString(false);
    }

    public String toString(boolean idOnly) {
	if (idOnly) {
	    return String.valueOf(getId());
	} else {
	    StringBuffer sb = new StringBuffer();
	    sb.append("T_bed_devicegroup_details[ ");
	    sb.append("Id=").append(getId()).append(" ");
	    if (getGroup() != null)
		sb.append("Group.Persist_ID=")
			.append(getGroup().toString(true)).append(" ");
	    else
		sb.append("Group=null ");
	    if (getPc() != null)
		sb.append("Pc.Persist_ID=").append(getPc().toString(true))
			.append(" ");
	    else
		sb.append("Pc=null ");
	    sb.append("MacAddress=").append(getMacAddress()).append(" ");
	    sb.append("Ip=").append(getIp()).append(" ");
	    sb.append("Port=").append(getPort()).append(" ");
	    if (getOs() != null)
		sb.append("Os.Persist_ID=").append(getOs().toString(true))
			.append(" ");
	    else
		sb.append("Os=null ");
	    sb.append("IsRemote=").append(getIsRemote()).append(" ");
	    sb.append("Name=").append(getName()).append(" ");
	    sb.append("]");
	    return sb.toString();
	}
    }

}
